<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>聊天室</title>
</head>

<body>
    <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
    <div id="main" style="height:400px"></div>
    <script src="${pageContext.request.contextPath}/js/jquery/jquery.js"></script>
	<script src="${pageContext.request.contextPath}/js/sockjs-0.3.4.js"></script>
    <script src="${pageContext.request.contextPath}/js/stomp.js"></script>
    <script type="text/javascript">
		var context_ = '<%=request.getContextPath()%>';

		function connect() {
            var socket = new SockJS(context_ + '/initWebsocket');
			stompClient = Stomp.over(socket);
            stompClient.connect({}, function(frame) {
                console.log('Connected: ' + frame);
                stompClient.subscribe('/message/weixin', function(calResult){
                	showResult(JSON.parse(calResult.body));
                });
            });
        };
        
        connect();
        
        function showResult(content) {
        	$('#main').append(content);
        }
    </script>
    
</body>